<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Config extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('config', ['engine' => 'MyISAM']);
        $table->addColumn('zh_field', 'string', ['limit' => 60, 'default' => '', 'comment' => '配置项中文名称'])
            ->addColumn('en_field', 'string', ['limit' => 60, 'default' => '', 'comment' => '配置项英文名称'])
            ->addColumn('default_value', 'string', ['limit' => 255, 'default' => '', 'comment' => '配置项默认值，多个以英文|分隔'])
            ->addColumn('subjoin_value', 'string', ['limit' => 255, 'default' => '', 'comment' => '配置项附加值或者键值对，多个以英文|分隔'])
            ->addColumn('subjoin_attr', 'string', ['limit' => 60, 'default' => '', 'comment' => '配置项附表单的DOM属性增加，多个以英文|分隔'])
            ->addColumn('lay-skin', 'string', ['limit' => 18, 'default' => 'primary', 'comment' => '配置项附表单的风格'])
            ->addColumn('lay-filter', 'string', ['limit' => 18, 'default' => '', 'comment' => '配置项附表单监听字段'])
            ->addColumn('explain', 'string', ['limit' => 255, 'default' => '', 'comment' => '配置项附加值或者键值对，多个以英文|分隔'])
            ->addColumn('sort', 'integer', ['limit' => 3, 'default' => 0, 'comment' => '配置项排序'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '配置项状态。1:正常；0:禁止'])
            ->addColumn('delete_time', 'datetime', ['default' => null, 'comment' => '软删除'])
            ->addColumn('config_type_id', 'integer', ['limit' => 6, 'comment' => '所属配置类型'])
            ->addColumn('fields_id', 'integer', ['limit' => 6, 'comment' => '所属数据字段类型'])
            ->create();
    }
}
